package com.indusfo.spc.controller;

import com.indusfo.spc.aspect.SystemControllerLog;
import com.indusfo.spc.pojo.ProcessSta;
import com.indusfo.spc.service.ProcessStaService;
import com.indusfo.spc.vo.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;


/**
 * @ProjectName: IEIS2-COM
 * @Package: com.indusfo.spc.controller
 * @ClassName: ProcessStaController
 * @Author: 熊冰
 * @Description: 流程工位 接口
 * @Date: 2019/9/4 16:41
 * @Version: 1.0
 */
@Controller
@RequestMapping("/processSta")
public class ProcessStaController {

    @Autowired
    private ProcessStaService processStaService;

    /**
     * 修改不良对策
     *
     * @param processSta
     * @return
     */
    @RequestMapping(value = "/updateProcessSta",method= RequestMethod.POST)
    @SystemControllerLog(description="修改流程工位")
    @ResponseBody
    public JSONObject updateProcessSta (ProcessSta processSta){

        JSONObject json=processStaService.updateProcessSta(processSta);

        return json;
    }

    /**
     * 查询
     *
     * @param
     * @return com.indusfo.spc.vo.JSONObject
     */
    @RequestMapping(value="/queryProcessSta")
    @SystemControllerLog(description="查询流程工位")
    @ResponseBody
    public JSONObject queryDep(ProcessSta processSta) {

        JSONObject json = processStaService.queryProcessSta(processSta);
        return json;

    }

    /**
     * 插入
     *
     * @return com.indusfo.spc.vo.JSONObject
     */
    @RequestMapping(value="/insertProcessSta", method= RequestMethod.POST)
    @SystemControllerLog(description="新增流程工位")
    @ResponseBody
    public JSONObject insertProcessSta(ProcessSta processSta) {

        JSONObject json = processStaService.insertProcessSta(processSta);
        return json;
    }

    /**
     * 启用/停用
     *
     * @param processStaIds, dataState
     * @return com.indusfo.spc.vo.JSONObject
     */
    @RequestMapping(value="/definesProcessSta", method= RequestMethod.POST)
    @SystemControllerLog(description="启用/停用流程工位")
    @ResponseBody
    public JSONObject definesProcessSta(@RequestParam("processStaIds")List<Integer> processStaIds, Integer dataState) {

        JSONObject json = processStaService.deleteProcessSta(processStaIds, dataState);
        return json;
    }

    /**
     * 删除
     *
     * @param processStaIds, dataState
     * @return com.indusfo.spc.vo.JSONObject
     */
    @RequestMapping(value="/deleteProcessSta", method= RequestMethod.POST)
    @SystemControllerLog(description="删除流程工位")
    @ResponseBody
    public JSONObject delProcessSta(@RequestParam("processStaIds")List<Integer>  processStaIds, Integer dataState) {

        dataState = 2;
        JSONObject json = processStaService.deleteProcessSta(processStaIds, dataState);
        return json;
    }

    /**
     * 查询可用工位
     * @param processSta
     * @return
     */
    @RequestMapping(value="/queryStation")
    @ResponseBody
    public JSONObject queryStation(ProcessSta processSta) {

        JSONObject json = processStaService.queryStation(processSta);
        return json;

    }

    /**
     * 查询可用工位
     * @param
     * @return
     */
    @RequestMapping(value="/changeStation")
    @ResponseBody
    public JSONObject changeStation(@RequestParam("StaIds")List<Integer> StaIds, Integer lProFlow) {
        JSONObject json = processStaService.changeStation(StaIds,lProFlow);
        return json;

    }
}
